package com.xingzhi.shortvideosharingplatform.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xingzhi.shortvideosharingplatform.dto.FollowingUserDTO;
import com.xingzhi.shortvideosharingplatform.model.UserFollow;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserFollowMapper extends BaseMapper<UserFollow> {
    
    /**
     * 获取用户关注的人列表
     * @param userId 用户ID
     * @return 关注的用户列表
     */
    @Select("SELECT u.id, u.nickname, u.avatar, u.signature " +
            "FROM user_follow uf " +
            "JOIN users u ON uf.following_id = u.id " +
            "WHERE uf.follower_id = #{userId} " +
            "ORDER BY uf.created_time DESC")
    List<FollowingUserDTO> getFollowingList(@Param("userId") Long userId);
} 